package display.camera;

/**
 * defines a camera for drawing the {@link world.World world}
 * @author jack
 *
 */
public class Camera
{
	/**
	 * the location of the camera in game space
	 */
	private double[] l;
	/**
	 * the view dimensions in game space, if this is not the same
	 * as the physical view dimensions the image displayed will,
	 * the location represents the top left corner of the rectangle
	 * formed by the game view dimensions
	 * be scaled appropriately
	 */
	private double[] gameViewDim;
	/**
	 * the view dimensions of the physical window or frame that the
	 * world is drawn in, for determining proper scaling
	 */
	private int[] physicalViewDim;
	/**
	 * creates a new camera
	 * @param l the location of the top left corner of the rectangle
	 * formed by the game view dimensions in game space
	 * @param gameViewDim the dimensions of the view in game space
	 * @param physicalViewDim the physical dimensions of the window
	 * or frame that actually displays the game
	 */
	public Camera(double[] l, double[] gameViewDim, int[] physicalViewDim)
	{
		this.l = l;
		this.gameViewDim = gameViewDim;
		this.physicalViewDim = physicalViewDim;
	}
	/**
	 * centers the game view on the specified location
	 * @param l
	 */
	public void centerView(double[] l)
	{
		this.l = new double[]{l[0]-gameViewDim[0]/2, l[1]-gameViewDim[1]/2};
	}
	/**
	 * returns the location of the top left corner of the rectangle
	 * defined by the game view dimensions
	 * @return returns the camera location
	 */
	public double[] getViewLocation()
	{
		return l;
	}
	/**
	 * returns the dimensions of the camera view in game space
	 * @return returns the game view dimensions
	 */
	public double[] getGameViewDim()
	{
		return gameViewDim;
	}
	/**
	 * gets the dimensions of the window or frame that the world will
	 * be drawn in
	 * @return returns the dimension of the physical view
	 */
	public int[] getPhysicalViewDim()
	{
		return physicalViewDim;
	}
	public void setGameViewDim(double[] v)
	{
		gameViewDim = v;
	}
	public void setPhysicalViewDim(int[] v)
	{
		physicalViewDim = v;
	}
}
